package com.bigegg.employee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.bigegg.employee.domain.ActivityOrder;
import com.bigegg.employee.service.IActivityOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 招聘会预定Controller
 * 
 * @author sun
 * @date 2022-08-15
 */
@RestController
@RequestMapping("/employee/order")
public class ActivityOrderController extends BaseController
{
    @Autowired
    private IActivityOrderService activityOrderService;

    /**
     * 查询招聘会预定列表
     */
    @PreAuthorize("@ss.hasPermi('employee:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityOrder activityOrder)
    {
        startPage();
        List<ActivityOrder> list = activityOrderService.selectActivityOrderList(activityOrder);
        return getDataTable(list);
    }

    /**
     * 导出招聘会预定列表
     */
    @PreAuthorize("@ss.hasPermi('employee:order:export')")
    @Log(title = "招聘会预定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityOrder activityOrder)
    {
        List<ActivityOrder> list = activityOrderService.selectActivityOrderList(activityOrder);
        ExcelUtil<ActivityOrder> util = new ExcelUtil<ActivityOrder>(ActivityOrder.class);
        util.exportExcel(response, list, "招聘会预定数据");
    }

    /**
     * 获取招聘会预定详细信息
     */
    @PreAuthorize("@ss.hasPermi('employee:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(activityOrderService.selectActivityOrderById(id));
    }

    /**
     * 新增招聘会预定
     */
    @PreAuthorize("@ss.hasPermi('employee:order:add')")
    @Log(title = "招聘会预定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityOrder activityOrder)
    {
        return toAjax(activityOrderService.insertActivityOrder(activityOrder));
    }

    /**
     * 修改招聘会预定
     */
    @PreAuthorize("@ss.hasPermi('employee:order:edit')")
    @Log(title = "招聘会预定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityOrder activityOrder)
    {
        return toAjax(activityOrderService.updateActivityOrder(activityOrder));
    }

    /**
     * 删除招聘会预定
     */
    @PreAuthorize("@ss.hasPermi('employee:order:remove')")
    @Log(title = "招聘会预定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activityOrderService.deleteActivityOrderByIds(ids));
    }
}
